﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class sqherev : MonoBehaviour
{
    private Rigidbody rbody;
    // Start is called before the first frame update
    void Start()
    {
        rbody = GetComponent<Rigidbody>();
    }

    // Update is called once per frame
    void Update()
    {
        //获取水平轴数值
        float horizontal = Input.GetAxis("Horizontal");
        //获取垂直轴数值
        float vertical = Input.GetAxis("Vertical");
        //获取移动方向向量
        Vector3 dir = new Vector3(horizontal, 0, vertical).normalized;
        //给刚体该方向上的速度
        rbody.velocity = dir * 2;
    }
}
